import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '*',
    redirect: '/login'
  },
  {
    path: '/article/:articleId',
    name: 'article',
    component: () => import(/* 文章详情路由组件 */ '@/views/article/index'),
    // 将路由动态参数映射到组件的 props 中，更推荐这种做法
    props: true
  },
  {
    path: '/search',
    name: 'search',
    component: () => import(/* 搜索页面路由组件 */ '@/views/search/index')
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* 登录页面路由组件 */ '@/views/login/login')
  },
  {
    path: '/tab-bar',
    name: 'tab-bar',
    component: () => import(/* 底部分类路由组件 */ '@/views/layout'),
    children: [
      {
        path: '/tab-bar/home',
        name: 'home',
        component: () => import(/* 分类内首页组件 */ '@/views/home/index')
      },
      {
        path: '/tab-bar/question',
        name: 'question',
        component: () => import(/* 分类内问答组件 */ '@/views/question/index')
      },
      {
        path: '/tab-bar/video',
        name: 'video',
        component: () => import(/* 分类内视频组件 */ '@/views/video/index')
      },
      {
        path: '/tab-bar/my',
        name: 'my',
        component: () => import(/* 分类内我的组件 */ '@/views/my/index')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
